home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
turbovis
/
tvtool17.zip
/
ACTLIB.ZIP
/
TOOLS.ZIP
/
SETCWD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-25
|
1KB
|
45 lines
/* Copyright (C) 1993 Marc Stern (internet: stern@mble.philips.be) */
#include "tools.h"
#include <stdlib.h>
#include <direct.h>
#include <ctype.h>
/***
*
* Function : setcwd
*
* Topics : change to specified directory accross disks
*
* Parameters : in char *dir input directory name
*
* Return code: 0 OK
* other Invalid syntax, drive or path
***/
int setcwd( const char *dir )
{ char drive[_MAX_DRIVE], buffer[_MAX_PATH];
int currentdisk = _getdrive();
_splitpath( dir, drive, buffer, buffer, buffer );
if ( *drive ) { int disk = toupper(*drive) - 'A' + 1;
_chdrive( disk );
if ( disk != _getdrive() )
{ _chdrive( currentdisk );
return -1;
}
}
if ( chdir(dir) ) { _chdrive( currentdisk );
return -1;
}
return 0;
}